package com.hua.scanner;

import java.util.Scanner;

public class Demo04 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        //从键盘接收数据
        int i = 0;
        float f = 0.01f;
        System.out.println("请输入整数");
        if (scanner.hasNextInt()){
            i = scanner.nextInt();
            System.out.println("整数数据："+i);
        }else {
            System.out.println("你输入的不是整数！");
        }

        System.out.println("请输入浮点数");
        if (scanner.hasNextFloat()){
            f = scanner.nextFloat();
            System.out.println("你输入的浮点数是："+f);
        }else {
            System.out.println("你输入的不是浮点数！");
        }



        scanner.close();
    }
}
